<?php 
require_once('library/template.php');
require('resources/const.php');     
//HOLY SHIT! FOLLOW THE FUCKING QUOTE CONVENTION IN THIS FILE! 
//could probably have php code in js and use a file read and prepend every line with document.write(

if (isset($_POST["rate"])) {
	$curl = new curlHelper();
	$curl->addHandle($BACKEND_URL."/api/rate/update.php","createUpdateResponse",
	array("postid"=>$_POST["postid"], "rating"=>$_POST["rating"]), true);
	$curl->exec();
}

?>

<div class='post' id='<?php echo $postid?>'>
	<h2 class='postid' id='header_<?php echo $postid?>'><a href='post.php?postid=<?php echo $postid?>'><?php echo $subject?></a></h2>
	<p><i>By <?php echo $user?> @ <?php echo $date?></i> views:<?php echo $views?></p>
	<?php if ($img != NULL) {echo "<img class='img' src='$img' alt='' />";}?>
	<p id='content_<?php echo $postid?>'><?php echo $content?><p/>
	<form name='rate' action='' method='post'>
	<select name='rating'>
	<!-- the different options could have hatelevelclasses different for each rating -->
 		<option value='1'<?php echo $rating==$HATELEVEL1?"selected='selected'":""?>><?php echo $HATELEVEL1?></option>
    	<option value='2'<?php echo $rating==$HATELEVEL2?"selected='selected'":""?>><?php echo $HATELEVEL2?></option>
    	<option value='3'<?php echo $rating==$HATELEVEL3?"selected='selected'":""?>><?php echo $HATELEVEL3?></option>
    	<option value='4'<?php echo $rating==$HATELEVEL4?"selected='selected'":""?>><?php echo $HATELEVEL4?></option>
    	<option value='5'<?php echo $rating==$HATELEVEL5?"selected='selected'":""?>><?php echo $HATELEVEL5?></option>
	</select>
	<input type='hidden' value=<?php echo $postid?> name='postid'></input>
	<!--<INPUT TYPE='button' NAME='button' Value='Submit' onclick='post(this.form);'/> -->
	<!--Do Support for pressing enter to submit and clearing the input fields-->
	<input type='submit' name='rate' value='Rate'/> 
</form>
</div>